package com.cskaoyan.bean.vo.back.ad;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


/**
 * 广告列表
 * 其中@JsonProperty注解表示更改bean字段的属性名
 * @author 李然
 * @date 2022/10/12
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AdListVo<T> {
    @JsonProperty("total")
    private Integer total;
    @JsonProperty("pages")
    private Integer pages;
    @JsonProperty("limit")
    private Integer limit;
    @JsonProperty("page")
    private Integer page;
    @JsonProperty("list")
    private List<?> list;

    public AdListVo(PageInfo<T> pageInfo, List<T> list) {
        this.total = Math.toIntExact(pageInfo.getTotal());
        this.pages = pageInfo.getPages();
        this.page = pageInfo.getPageNum();
        this.limit = pageInfo.getPageSize();
        this.list = list;
    }
}
